package org.langke.springboot3;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@SpringBootApplication
public class MyApplication {

    @RequestMapping("/")
    String home(HttpServletRequest request) {
        List<String> headers = new ArrayList<>();
        request.getHeaderNames().asIterator().forEachRemaining(s -> {
            headers.add(request.getHeader(s));
            System.out.println(s+":"+request.getHeader(s));
        });
        return "Hello World!"+ headers;
    }

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

}


